package com.springapp.fed.mvc.facade;

import com.springapp.fed.domain.model.UserData;
import com.springapp.fed.domain.service.FraudDetectionService;
import com.springapp.fed.rule.engine.RuleManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;

/**
 * Created with IntelliJ IDEA.
 * User: WENKY
 * Date: 10/31/13
 * Time: 9:35 PM
 * To change this template use File | Settings | File Templates.
 */
@Component
public class FraudDetectionFacade {
    @Autowired
    FraudDetectionService fraudDetectionService;
    @Autowired
    RuleManager ruleManager;

    public void processFraudDetection(Model model) {
        try {
            fraudDetectionService.processFraudDetection(model);
            model.addAttribute("fraudrate",ruleManager.getFraudRate((UserData)model.asMap().get("userdata")));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
